import request from '@/utils/request'
export const  getCategoryAPI= ()=>request.get('/home/category/head') 

export const getBannerApi= (distributionSite)=>request.get('/home/banner',{params:{distributionSite:distributionSite||'1'}})

export const getNewGoodsApi= ()=>request.get('/home/new')

export const getHotGoodsApi= ()=>request.get('/home/hot')

export const getBrandGoodsApi= ()=>request.get('/home/goods')

export const getNextCategoryAPI= (id)=>request.get('/category',{params:{id}})

export const getCategoryFilterAPI= (id)=>request.get('/category/sub/filter',{params:{id}})

export const getSubCategoryAPI = (data) => {
    return request({
      url:'/category/goods/temporary',
      method:'POST',
      data
    })
  }

export const getGoodsDetailAPI = (id) => {
    return request.get('/goods',{params:{id}})
  }

/**
 * 获取热榜商品
 * @param {Number} id - 商品id
 * @param {Number} type - 1代表24小时热销榜 2代表周热销榜
 * @param {Number} limit - 获取个数
 */
export const fetchHotGoodsAPI = ({ id, type, limit = 3 }) => {
  return request({
    url:'/goods/hot',
    params:{
      id, 
      type, 
      limit
    }
  })
}

export const getUserInfoAPI = ({account,password}) => {
  return request.post('/login',{account,password})  
}

export const getLikeListAPI = ({ limit = 4 }) => {
  return request({
    url:'/goods/relevant',
    params: {
      limit 
    }
  })
}


export const getUserOrderApi = (params) => {
  return request({
    url:'/member/order',
    method:'GET',
    params
  })
}